package com.yxym.customexception_;

public class CustomException01 {
    public static void main(String[] args) {
        int age = 80;
        if (!(age >= 18 && age <= 120)){
            throw new AgeException("年龄需在18-120范围之间...");
        }
        System.out.println("范围正确...");
    }
}
//自定义一个异常
class AgeException extends RuntimeException{
    public AgeException(String message){//构造器
        super(message);
    }
}